package com.example.demo.intercept.config;

import com.example.demo.intercept.DomainIntercept;
import com.example.demo.intercept.RequestIntercept;
import com.example.demo.intercept.UrlIntercept;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

@Configuration
public class InterceptConfig extends WebMvcConfigurerAdapter {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {

        /*配置跨域拦截器*/
        registry.addInterceptor(new DomainIntercept())
                .addPathPatterns("/**");

        /*安全认证拦截器*/


//        registry.addInterceptor(new RequestIntercept())
//                .addPathPatterns("/**")
//                .excludePathPatterns("/toLogin")
//                .excludePathPatterns("/customer");

//        registry.addInterceptor(new RequestIntercept())
//                .addPathPatterns("/**")
//                .excludePathPatterns("/toLogin");


        /*操作权限拦截器*/
        registry.addInterceptor(new UrlIntercept())
                .addPathPatterns("/**")
                .excludePathPatterns("/getRedisToken");
        super.addInterceptors(registry);
    }

}
